package com.jiangjiang.eshop.wms.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jiangjiang.eshop.wms.convert.WmsGoodsAllocationStockDetailConvert;
import com.jiangjiang.eshop.wms.dao.WmsGoodsAllocationStockDetailMapper;
import com.jiangjiang.eshop.wms.domain.WmsGoodsAllocationStockDetail;
import com.jiangjiang.eshop.wms.dto.GoodsAllocationStockDetailDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Wrapper;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @ClassName WmsGoodsAllocationStockDetailService
 * @Description TODO
 * @Author jhw
 * @Date 2021/9/14 20:02
 * @Version 1.0
 **/
@Service
public class WmsGoodsAllocationStockDetailService extends ServiceImpl<WmsGoodsAllocationStockDetailMapper, WmsGoodsAllocationStockDetail> {

    @Autowired
    private WmsGoodsAllocationStockDetailConvert goodsAllocationStockDetailConvert;

    /**
     * 根据id集合查询货位库存明细数据
     * @param sendOutDetailIds
     * @return
     */
    public List<WmsGoodsAllocationStockDetail> queryByIds(List<Long> sendOutDetailIds) {
        LambdaQueryWrapper<WmsGoodsAllocationStockDetail> wrapper = Wrappers.lambdaQuery();
        wrapper.in(WmsGoodsAllocationStockDetail::getId, sendOutDetailIds);
        return this.list(wrapper);
    }


    /**
     * 数据转换
     *
     * @param details
     * @return
     */
    public List<GoodsAllocationStockDetailDTO> convertEntities2DTOList(List<WmsGoodsAllocationStockDetail> details) {
        return goodsAllocationStockDetailConvert.convertEntities2DTOList(details);
    }
}
